<?php
// +----------------------------------------------------------------------
// | snake
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\index\validate;

use think\Validate;

class ApplyBrokerageValidate extends Validate
{

    protected $rule = [
        ['share_ratio|分享人比例', 'require|number|between:0, 10'],
        ['vote_ratio|投票人比例', 'require|number|between:0, 10'],
        ['min_money|最低红包', 'require|float|egt:0|checkMoney'],
        ['max_money|最高红包', 'require|float|egt:0']
    ];

    protected $scene = [
        'add'=>['share_ratio','vote_ratio','min_money','max_money'],
        'edit'=>['share_ratio','vote_ratio','min_money','max_money'],
    ];


    public function checkMoney($value, $rule, $data){
        if($value > $data['max_money']) {
            return '红包设置有误';
        } else {
            return true;
        }
    }



}
